package com.mybaits.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @description: 模拟动态数据库
 * @author: zyj
 * @create: 2019-11-27 17:06
 **/
public class DataUrlMap {

    public static Map<String, String> getMap(String code){
        List<Map<String, String>> dataList = createDatabaseInfo();

        for(Map<String, String> map : dataList){
            String codeLo = map.get("dataCode");
            if(codeLo.equals(code)){
                return map;
            }
        }

        return null;
    }

    public static List<Map<String, String>> createDatabaseInfo(){
        List<Map<String, String>> dataList = new ArrayList<>();
        Map map1 = new HashMap();
        map1.put("dataCode", "model-1");
        map1.put("databaseUrl", "192.168.137.11");
        map1.put("databasePort", "3306");
        map1.put("tenantDatabase", "smjjuser");
        map1.put("tenantDatabaseName", "root");
        map1.put("tenantDatabasePasswd", "123456");
        map1.put("drivername", "com.mysql.jdbc.Driver");
        dataList.add(map1);

        Map map2 = new HashMap();
        map2.put("dataCode", "model-2");
        map2.put("databaseUrl", "192.168.137.11");
        map2.put("databasePort", "3306");
        map2.put("tenantDatabase", "testuser");
        map2.put("tenantDatabaseName", "root");
        map2.put("tenantDatabasePasswd", "123456");
        map2.put("drivername", "com.mysql.jdbc.Driver");
        dataList.add(map2);

        Map map3 = new HashMap();
        map3.put("dataCode", "model-3");
        map3.put("databaseUrl", "192.168.137.11");
        map3.put("databasePort", "3306");
        map3.put("tenantDatabase", "hotel");
        map3.put("tenantDatabaseName", "root");
        map3.put("tenantDatabasePasswd", "123456");
        map3.put("drivername", "com.mysql.jdbc.Driver");
        dataList.add(map3);

        return dataList;
    }
}
